import torch
import init

def text2Vec(text):
    vec = torch.zeros(init.captcha_size, len(init.captcha_array))
    # print(vec)
    for i in range(len(text)):
        # print(init.captcha_array.index(text[i]))
        vec[i, init.captcha_array.index(text[i])] = 1
    return vec

def vec2Text(vec):
    vec = torch.argmax(vec, dim=1)
    text = ""
    for i in vec:
        text += init.captcha_array[i]
    return text

if __name__ == '__main__':
    vec = text2Vec("aabc")
    text = vec2Text(vec)
    # print(text)